<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>json数据转换与本地存储及$scope数据序列化提交到后台</title>
    <script src="./lib/angular.min.js"></script>
    <script src="./lib/jquery.min.js"></script>
</head>
<body ng-app="wu">
<div ng-controller="ctrl">
    {{data}} -- {{data.name}}

    <form action="./php/json.php" method="post">
        <p>
            <label for="">标题：</label>
            <input type="text" ng-model="field.title">
        </p>
        <p>
            <label for="">点击：</label>
            <input type="text" ng-model="field.click">
        </p>
        <p>
            <textarea name="data"></textarea>
            <input type="submit" value="提交一下">
        </p>

    </form>


</div>
<script>
    var m = angular.module('wu', []);
    m.controller('ctrl', ['$scope', function (scope) {
        /*
        scope.data = {'name': 'PHP'}
        localStorage.setItem('data',angular.toJson(scope.data));
        */

        //scope.data = angular.fromJson(localStorage.getItem('data'));

        //scope.data = angular.fromJson('{"name":"php"}');

        scope.field = {'title':'','click':100}

        $('form').submit(function () {

            return false;
        });

    }]);
</script>

</body>
</html>